*****************************************************************************************************************************************************
* PROJECT: 		WEALTH LOSSES DUE TO CORONA PANDEMIC
* DATE: 		2020-November
* CONTENT: 		Table A13 - Changes in expected retirement age across groups
* AUTHORS: 		Tobin Hanspal, Johannes Wohlfart, Anni Weber
*****************************************************************************************************************************************************

		clear all
		set scheme lean2
		global pm = char(177)
		set more off
		gl date = c(current_date)
		graph set window fontface "cmr10"		
		
* set cd as /Replication_files_HanspalWeberWohlfart2020/

*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~						
** Table A13
*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~	
	
use data/processed/data_1, clear

keep if control_pure==1 |control_fincrisis==1 | control_dotcom==1 | control_black==1 

tab employment_situation, sort
bysort expec_retireage3: tab employment_situation

label variable expec_retirlater "retire later"
label variable expec_retirearly "retire early"

gen employed_aux=(employment_situation==1 | employment_situation==2 | employment_situation==9 |employment_situation==7)
tab employed_aux


local  vars  expec_retirlater 
		
		eststo a1: qui estpost tabstat `vars'  , stats(mean ) 
		eststo a2: qui estpost tabstat `vars' if male==1  , stats(mean  )  
		eststo a3: qui estpost tabstat `vars' if male==0  , stats(mean  )  
		
		eststo a4: qui estpost tabstat `vars' if agecat==1  , stats(mean) columns(statistics) 
		eststo a5: qui estpost tabstat `vars' if agecat==2  , stats(mean ) columns(statistics) 
		eststo a6: qui estpost tabstat `vars' if agecat==3  , stats(mean ) columns(statistics) 
		eststo a7: qui estpost tabstat `vars' if agecat==4  , stats(mean ) columns(statistics) 
		eststo a8: qui estpost tabstat `vars' if agecat==5  , stats(mean ) columns(statistics) 
		eststo a9: qui estpost tabstat `vars' if agecat==6  , stats(mean ) columns(statistics) 
		
		eststo a11: qui estpost tabstat `vars' if education==2  , stats(mean ) columns(statistics) 
		eststo a12: qui estpost tabstat `vars' if education==3  | education==4 , stats(mean ) columns(statistics) 
		eststo a14: qui estpost tabstat `vars' if education==5  | education==6 , stats(mean ) columns(statistics) 
		
		eststo a16: qui estpost tabstat `vars' if hhnetinc_2019_grp==1  , stats(mean ) columns(statistics) 
		eststo a17: qui estpost tabstat `vars' if hhnetinc_2019_grp==2  , stats(mean ) columns(statistics) 
		eststo a18: qui estpost tabstat `vars' if hhnetinc_2019_grp==3  , stats(mean ) columns(statistics) 
		eststo a19: qui estpost tabstat `vars' if hhnetinc_2019_grp==4  , stats(mean ) columns(statistics) 
		eststo a20: qui estpost tabstat `vars' if hhnetinc_2019_grp==5  , stats(mean ) columns(statistics) 
			
		esttab a1 a2 a3 , replace  /// 
		cells("mean(fmt(%15.3fc)) & min(fmt(%15.2fc)) & max(fmt(%15.2fc)) & sd(fmt(%15.2fc)) & p(fmt(2))")  /// 
		mtitle("all" "male" "female" ) /// 
		collabels("mean" "sd" "min" "max" "mean" "mean"  "p-value" )  fragment label	
		
			
		esttab a4 a5 a6 a7 a8 a9 , replace  /// 
		cells("mean(fmt(%15.3fc)) & min(fmt(%15.2fc)) & max(fmt(%15.2fc)) & sd(fmt(%15.2fc)) & p(fmt(2))")  /// 
		mtitle("18-24" "25-34" "35-44" "35-44" "55-64" "65+" ) /// 
		collabels("mean" "sd" "min" "max" "mean" "mean"  "p-value" )  fragment label	
		
		
		esttab a11 a12 a14 , replace  /// 
		cells("mean(fmt(%15.3fc)) & min(fmt(%15.2fc)) & max(fmt(%15.2fc)) & sd(fmt(%15.2fc)) & p(fmt(2))")  /// 
		mtitle("HS" "some college/Assoc." "At least bachelor"  ) /// 
		collabels("mean" "sd" "min" "max" "mean" "mean"  "p-value" )  fragment label	
		
		
		esttab a16 a17 a18 a19 a20, replace  /// 
		cells("mean(fmt(%15.3fc)) & min(fmt(%15.2fc)) & max(fmt(%15.2fc)) & sd(fmt(%15.2fc)) & p(fmt(2))")  /// 
		mtitle("1" "2" "3" "4" "5" ) /// 
		collabels("mean" "sd" "min" "max" "mean" "mean"  "p-value" )  fragment label	
		

local  vars  expec_retirlater 
		
		eststo a1: qui estpost tabstat `vars' if agecat>4 , stats(mean ) 
		eststo a2: qui estpost tabstat `vars' if male==1 & agecat>4 , stats(mean  )  
		eststo a3: qui estpost tabstat `vars' if male==0 & agecat>4 , stats(mean  )  
		
		eststo a8: qui estpost tabstat `vars' if agecat==5 & agecat>4 , stats(mean ) columns(statistics) 
		eststo a9: qui estpost tabstat `vars' if agecat==6 & agecat>4 , stats(mean ) columns(statistics) 
		
		eststo a11: qui estpost tabstat `vars' if education==2 & agecat>4 , stats(mean ) columns(statistics) 
		eststo a12: qui estpost tabstat `vars' if education==3  & agecat>4| education==4 & agecat>4, stats(mean ) columns(statistics) 
		eststo a14: qui estpost tabstat `vars' if education==5 & agecat>4 | education==6& agecat>4 , stats(mean ) columns(statistics) 
		
		eststo a16: qui estpost tabstat `vars' if hhnetinc_2019_grp==1 & agecat>4 , stats(mean ) columns(statistics) 
		eststo a17: qui estpost tabstat `vars' if hhnetinc_2019_grp==2 & agecat>4 , stats(mean ) columns(statistics) 
		eststo a18: qui estpost tabstat `vars' if hhnetinc_2019_grp==3 & agecat>4 , stats(mean ) columns(statistics) 
		eststo a19: qui estpost tabstat `vars' if hhnetinc_2019_grp==4 & agecat>4 , stats(mean ) columns(statistics) 
		eststo a20: qui estpost tabstat `vars' if hhnetinc_2019_grp==5 & agecat>4 , stats(mean ) columns(statistics) 
			
		esttab a1 a2 a3 , replace  /// 
		cells("mean(fmt(%15.3fc)) & min(fmt(%15.2fc)) & max(fmt(%15.2fc)) & sd(fmt(%15.2fc)) & p(fmt(2))")  /// 
		mtitle("all" "male" "female" ) /// 
		collabels("mean" "sd" "min" "max" "mean" "mean"  "p-value" )  fragment label	
		
			
		esttab  a8 a9 , replace  /// 
		cells("mean(fmt(%15.3fc)) & min(fmt(%15.2fc)) & max(fmt(%15.2fc)) & sd(fmt(%15.2fc)) & p(fmt(2))")  /// 
		mtitle( "55-64" "65+" ) /// 
		collabels("mean" "sd" "min" "max" "mean" "mean"  "p-value" )  fragment label	
		
		
		esttab a11 a12 a14 , replace  /// 
		cells("mean(fmt(%15.3fc)) & min(fmt(%15.2fc)) & max(fmt(%15.2fc)) & sd(fmt(%15.2fc)) & p(fmt(2))")  /// 
		mtitle("HS" "some college/Assoc." "At least bachelor"  ) /// 
		collabels("mean" "sd" "min" "max" "mean" "mean"  "p-value" )  fragment label	
		
		
		esttab a16 a17 a18 a19 a20, replace  /// 
		cells("mean(fmt(%15.3fc)) & min(fmt(%15.2fc)) & max(fmt(%15.2fc)) & sd(fmt(%15.2fc)) & p(fmt(2))")  /// 
		mtitle("1" "2" "3" "4" "5" ) /// 
		collabels("mean" "sd" "min" "max" "mean" "mean"  "p-value" )  fragment label	
		
		

local  vars  expec_retirearly 
		
		eststo a1: qui estpost tabstat `vars'  , stats(mean ) 
		eststo a2: qui estpost tabstat `vars' if male==1  , stats(mean  )  
		eststo a3: qui estpost tabstat `vars' if male==0  , stats(mean  )  
		
		eststo a4: qui estpost tabstat `vars' if agecat==1  , stats(mean) columns(statistics) 
		eststo a5: qui estpost tabstat `vars' if agecat==2  , stats(mean ) columns(statistics) 
		eststo a6: qui estpost tabstat `vars' if agecat==3  , stats(mean ) columns(statistics) 
		eststo a7: qui estpost tabstat `vars' if agecat==4  , stats(mean ) columns(statistics) 
		eststo a8: qui estpost tabstat `vars' if agecat==5  , stats(mean ) columns(statistics) 
		eststo a9: qui estpost tabstat `vars' if agecat==6  , stats(mean ) columns(statistics) 
		
		eststo a11: qui estpost tabstat `vars' if education==2  , stats(mean ) columns(statistics) 
		eststo a12: qui estpost tabstat `vars' if education==3  | education==4 , stats(mean ) columns(statistics) 
		eststo a14: qui estpost tabstat `vars' if education==5  | education==6 , stats(mean ) columns(statistics) 
		
		eststo a16: qui estpost tabstat `vars' if hhnetinc_2019_grp==1  , stats(mean ) columns(statistics) 
		eststo a17: qui estpost tabstat `vars' if hhnetinc_2019_grp==2  , stats(mean ) columns(statistics) 
		eststo a18: qui estpost tabstat `vars' if hhnetinc_2019_grp==3  , stats(mean ) columns(statistics) 
		eststo a19: qui estpost tabstat `vars' if hhnetinc_2019_grp==4  , stats(mean ) columns(statistics) 
		eststo a20: qui estpost tabstat `vars' if hhnetinc_2019_grp==5  , stats(mean ) columns(statistics) 
			
		esttab a1 a2 a3 , replace  /// 
		cells("mean(fmt(%15.3fc)) & min(fmt(%15.2fc)) & max(fmt(%15.2fc)) & sd(fmt(%15.2fc)) & p(fmt(2))")  /// 
		mtitle("all" "male" "female" ) /// 
		collabels("mean" "sd" "min" "max" "mean" "mean"  "p-value" )  fragment label	
		
			
		esttab a4 a5 a6 a7 a8 a9 , replace  /// 
		cells("mean(fmt(%15.3fc)) & min(fmt(%15.2fc)) & max(fmt(%15.2fc)) & sd(fmt(%15.2fc)) & p(fmt(2))")  /// 
		mtitle("18-24" "25-34" "35-44" "35-44" "55-64" "65+" ) /// 
		collabels("mean" "sd" "min" "max" "mean" "mean"  "p-value" )  fragment label	
		
		
		esttab a11 a12 a14 , replace  /// 
		cells("mean(fmt(%15.3fc)) & min(fmt(%15.2fc)) & max(fmt(%15.2fc)) & sd(fmt(%15.2fc)) & p(fmt(2))")  /// 
		mtitle("HS" "some college/Assoc." "At least bachelor"  ) /// 
		collabels("mean" "sd" "min" "max" "mean" "mean"  "p-value" )  fragment label	
		
		
		esttab a16 a17 a18 a19 a20, replace  /// 
		cells("mean(fmt(%15.3fc)) & min(fmt(%15.2fc)) & max(fmt(%15.2fc)) & sd(fmt(%15.2fc)) & p(fmt(2))")  /// 
		mtitle("1" "2" "3" "4" "5" ) /// 
		collabels("mean" "sd" "min" "max" "mean" "mean"  "p-value" )  fragment label	
		

local  vars  expec_retirearly 
		
		eststo a1: qui estpost tabstat `vars' if agecat>4 , stats(mean ) 
		eststo a2: qui estpost tabstat `vars' if male==1 & agecat>4 , stats(mean  )  
		eststo a3: qui estpost tabstat `vars' if male==0 & agecat>4 , stats(mean  )  
		
		eststo a8: qui estpost tabstat `vars' if agecat==5 & agecat>4 , stats(mean ) columns(statistics) 
		eststo a9: qui estpost tabstat `vars' if agecat==6 & agecat>4 , stats(mean ) columns(statistics) 
		
		eststo a11: qui estpost tabstat `vars' if education==2 & agecat>4 , stats(mean ) columns(statistics) 
		eststo a12: qui estpost tabstat `vars' if education==3  & agecat>4| education==4 & agecat>4, stats(mean ) columns(statistics) 
		eststo a14: qui estpost tabstat `vars' if education==5 & agecat>4 | education==6& agecat>4 , stats(mean ) columns(statistics) 
		
		eststo a16: qui estpost tabstat `vars' if hhnetinc_2019_grp==1 & agecat>4 , stats(mean ) columns(statistics) 
		eststo a17: qui estpost tabstat `vars' if hhnetinc_2019_grp==2 & agecat>4 , stats(mean ) columns(statistics) 
		eststo a18: qui estpost tabstat `vars' if hhnetinc_2019_grp==3 & agecat>4 , stats(mean ) columns(statistics) 
		eststo a19: qui estpost tabstat `vars' if hhnetinc_2019_grp==4 & agecat>4 , stats(mean ) columns(statistics) 
		eststo a20: qui estpost tabstat `vars' if hhnetinc_2019_grp==5 & agecat>4 , stats(mean ) columns(statistics) 
			
		esttab a1 a2 a3 , replace  /// 
		cells("mean(fmt(%15.3fc)) & min(fmt(%15.2fc)) & max(fmt(%15.2fc)) & sd(fmt(%15.2fc)) & p(fmt(2))")  /// 
		mtitle("all" "male" "female" ) /// 
		collabels("mean" "sd" "min" "max" "mean" "mean"  "p-value" )  fragment label	
		
			
		esttab a11 a12 a14 , replace  /// 
		cells("mean(fmt(%15.3fc)) & min(fmt(%15.2fc)) & max(fmt(%15.2fc)) & sd(fmt(%15.2fc)) & p(fmt(2))")  /// 
		mtitle("HS" "some college/Assoc." "At least bachelor"  ) /// 
		collabels("mean" "sd" "min" "max" "mean" "mean"  "p-value" )  fragment label	
		
		
		esttab a16 a17 a18 a19 a20, replace  /// 
		cells("mean(fmt(%15.3fc)) & min(fmt(%15.2fc)) & max(fmt(%15.2fc)) & sd(fmt(%15.2fc)) & p(fmt(2))")  /// 
		mtitle("1" "2" "3" "4" "5" ) /// 
		collabels("mean" "sd" "min" "max" "mean" "mean"  "p-value" )  fragment label	
		
		
		
		local  vars  expec_retirearly expec_retirlater
		
		eststo a1: qui estpost tabstat `vars' if agecat>4 , stats(mean ) columns(statistics) 
		eststo a2: qui estpost tabstat `vars' if male==1 & agecat>4  , stats(mean  ) columns(statistics) 
		eststo a3: qui estpost tabstat `vars' if male==0 & agecat>4 , stats(mean  ) columns(statistics) 
		eststo a8: qui estpost tabstat `vars' if agecat==5 & agecat>4 , stats(mean ) columns(statistics) 
		eststo a9: qui estpost tabstat `vars' if agecat==6 & agecat>4 , stats(mean ) columns(statistics) 
		eststo a10: qui estpost tabstat `vars' if education==2 & agecat>4 , stats(mean ) columns(statistics) 
		eststo a11: qui estpost tabstat `vars' if education==3 & agecat>4 | education==4 & agecat>4 , stats(mean ) columns(statistics) 
		eststo a12: qui estpost tabstat `vars' if education==5 & agecat>4 | education==6 & agecat>4 , stats(mean ) columns(statistics) 
		eststo a16: qui estpost tabstat `vars' if hhnetinc_2019_grp==1 & agecat>4 , stats(mean ) columns(statistics) 
		eststo a17: qui estpost tabstat `vars' if hhnetinc_2019_grp==2 & agecat>4 , stats(mean ) columns(statistics) 
		eststo a18: qui estpost tabstat `vars' if hhnetinc_2019_grp==3 & agecat>4 , stats(mean ) columns(statistics) 
		eststo a19: qui estpost tabstat `vars' if hhnetinc_2019_grp==4 & agecat>4 , stats(mean ) columns(statistics) 
		eststo a20: qui estpost tabstat `vars' if hhnetinc_2019_grp==5 & agecat>4 , stats(mean ) columns(statistics) 
		
	
		esttab a1 a2 a3 , replace  /// 
		cells("mean(fmt(%15.3fc)) & min(fmt(%15.2fc)) & max(fmt(%15.2fc)) & sd(fmt(%15.2fc)) & p(fmt(2))")  /// 
		mtitle("all" "male" "female" ) /// 
		collabels("mean" "sd" "min" "max" "mean" "mean"  "p-value" )  fragment label	
		
			
		esttab  a8 a9 , replace  /// 
		cells("mean(fmt(%15.3fc)) & min(fmt(%15.2fc)) & max(fmt(%15.2fc)) & sd(fmt(%15.2fc)) & p(fmt(2))")  /// 
		mtitle( "55-64" "65+" ) /// 
		collabels("mean" "sd" "min" "max" "mean" "mean"  "p-value" )  fragment label	
		
		
		esttab a10 a11 a12 , replace  /// 
		cells("mean(fmt(%15.3fc)) & min(fmt(%15.2fc)) & max(fmt(%15.2fc)) & sd(fmt(%15.2fc)) & p(fmt(2))")  /// 
		mtitle("HS" "some college" "bachelor+" ) /// 
		collabels("mean" "sd" "min" "max" "mean" "mean"  "p-value" )  fragment label	
		
		
		esttab a16 a17 a18 a19 a20, replace  /// 
		cells("mean(fmt(%15.3fc)) & min(fmt(%15.2fc)) & max(fmt(%15.2fc)) & sd(fmt(%15.2fc)) & p(fmt(2))")  /// 
		mtitle("1" "2" "3" "4" "5" ) /// 
		collabels("mean" "sd" "min" "max" "mean" "mean"  "p-value" )  fragment label	
		
		
	